package com.xykj.deploy.config;

import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.Session;

import java.io.OutputStream;

/**
 * @author Ethan
 * @version 1.0
 * @description: TODO
 * @date 2024-12-02 17:07
 */
public record SSHSession(Session session, ChannelShell channel, OutputStream outputStream) {

    public void close() {
        try {
            if (channel != null && channel.isConnected()) {
                channel.disconnect();
            }
            if (session != null && session.isConnected()) {
                session.disconnect();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
